#include <bits/stdc++.h>
// 2025/01/27
// tag: 
// Author: Zhang Muen
using namespace std;

int n, a[100001], dp[31];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int maxn = 0;
        for (int j = 0; j <= 30; j++)
            if (a[i] & (1 << j))
                maxn = max(maxn, dp[j] + 1);
        for (int j = 0; j <= 30; j++)
            if (a[i] & (1 << j))
                dp[j] = max(dp[j], maxn);
        ans = max(ans, maxn);
    }
    cout << ans << endl;
    return 0;
}